package com.jjb.www.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallback;
import com.hjq.shape.view.ShapeButton;
import com.hjq.shape.view.ShapeImageView;
import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppActivity;
import com.jjb.www.http.api.CurriculumSortApi;
import com.jjb.www.http.api.GraduationApi;
import com.jjb.www.http.glide.GlideApp;
import com.jjb.www.http.httputil.HttpUtis;
import com.jjb.www.http.model.HttpData;
import com.jjb.www.http.model.HttpList;
import com.jjb.www.ui.fragment.CourseListFragment;
/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/10/18Evaluation
 *    desc   : 结业证明
 */
public class GraduationActivity extends AppActivity {

    private String id;
    private ShapeImageView mImgZs;
    private ShapeButton mBtnDown;
    private ShapeTextView mTvNext;
    private String downUrl = "";



    @Override
    protected int getLayoutId() {
        return R.layout.activity_graduation;
    }

    @Override
    protected void initView() {
        mImgZs = findViewById(R.id.img_zs);
        mBtnDown = findViewById(R.id.btn_down);
        mTvNext = findViewById(R.id.tv_next);
        mTvNext.setPaintFlags(mTvNext.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        setOnClickListener(mBtnDown,mTvNext);
    }

    @Override
    public void onClick(View view) {
        if (view==mBtnDown){
            HttpUtis.downLoad(GraduationActivity.this,GraduationActivity.this,downUrl);
        }else if (view==mTvNext){
            Intent intent = new Intent();
            intent.putExtra("id",id);
            intent.setClass(this,CompleteDetailActivity.class);
            startActivity(intent);
        }
    }

    @Override
    protected void initData() {
        id = getString("id");
        EasyHttp.get(this)
                .api(new GraduationApi()
                .setId(id))
                .request(new HttpCallback<HttpData<GraduationApi.Bean>>(this) {

                    @Override
                    public void onSucceed(HttpData<GraduationApi.Bean> data) {
                        downUrl = data.getData().getUrl();
                        GlideApp.with(getContext())
                                .load(data.getData().getImg_url())
                                .into(mImgZs);
                    }

                });
    }
}